import config from '../config/index.js'

import { ElMessage } from 'element-plus'

export default function upload(module, file) {
  const base = window.location.host
  const url = `http://${base}/api/${module}`
  
  config.axios.post(url, file).then(res => {
    // console.log('上传返回', res)
    const code = res.data.code
    if (code === 0) {
      ElMessage({
        message: '上传成功！',
        type: 'success',
      })  
    } else {
      ElMessage.error('上传失败！')
    }
    
  })
}